// 最多1000个整数和浮点数，整数从大到小排列，浮点数从小到大

// 使用两次冒泡排序

#include "stdio.h"

double absolute(double num){
    return num > 0 ? num : -num;
}

int isInt(double num){
    return absolute((int)num - num) < 0.000001;
}

void swap(double *a, double *b){
    double t = *a;
    *a = *b;
    *b = t;
}

void sort(double nums[], int n){
    // 对整数排序
    for (int i=0; i<n; ++i) {
        if(!isInt(nums[i])) continue;
        for(int j = i; j<n;++j){
            if(!isInt(nums[j])) continue;
            if(nums[i] < nums[j]){
                swap(nums + i, nums + j);
            }
        }     
    }

    // 对浮点数排序
    for (int i=0; i<n; ++i) {
        if(isInt(nums[i])) continue;
        for(int j = i; j<n;++j){
            if(isInt(nums[j])) continue;
            if(nums[i] > nums[j]){
                swap(nums + i, nums + j);
            }
        }     
    }
}


int main(){
    int n = 9;
    double nums[] = {1, 5, 11.5, 4, 7, 5.5, 6.2, 70 ,2.1};
    sort(nums, n);
    for (int i=0; i<n; ++i) {
        printf("%g ",nums[i]);
    }
    return 0;
}